package com.fadadianqi.mall.product.dao.ibatis;

import com.fadadianqi.commons.GenericDAOSuport;
import com.fadadianqi.mall.product.dao.AttrRelationDAO;
import com.fadadianqi.mall.product.model.AttrRelation;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by aroot on 2/12/14.
 */
@Component
public class AttrRelationDAOImpl extends GenericDAOSuport<String, AttrRelation> implements AttrRelationDAO {
    @Override
    protected Class<?> getObjectClass() {
        return AttrRelation.class;
    }

    @Override
    protected String getTableName() {
        return "mall_nav_attr";
    }

    @Override
    public AttrRelation getByNavIdAndAttrNameId(String navId, String attrNameId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("relationId", navId);
        map.put("type", AttrRelation.TYPE_NAV);
        map.put("attrNameId", attrNameId);
        return super.getByPropertys(map);
    }

    @Override
    public List<AttrRelation> findByNavId(String navId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("relationId", navId);
        map.put("type", AttrRelation.TYPE_NAV);
        return super.findByPropertys(map);
    }
}
